﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class PersonRegieter : System.Web.UI.Page
{
    private TBperson tbp;
    private Register re;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Session["person"] == null)
        {
            tbp = new TBperson();
            re = new Register();
            tbp.Pid = re.autoID();
            tbp.Pname = txtname.Text.Trim();
            tbp.Ppwd = MD5.EncodeMD5(this.txtpwd.Text.Trim());
            if (rbgg.Checked == true)
            {
                tbp.Psex = rbgg.Text.Trim();
            }
            if (rbmm.Checked == true)
            {
                tbp.Psex = rbmm.Text.Trim();
            }
            tbp.Page = this.txtage.Text.Trim();
            tbp.Phouseholder = ddlp.SelectedItem.Text.Trim() + "省" + ddlc.SelectedItem.Text.Trim() + "市";
            tbp.Padd = ddlnp.SelectedItem.Text.Trim() + "省" + ddlnc.SelectedItem.Text.Trim() + "市";
            tbp.Pschool = this.txtschool.Text.Trim();
            tbp.Ptel = this.txttel.Text.Trim();
            tbp.Pemail = this.txtmail.Text.Trim();
            tbp.Pknowledge = this.ddlpk.SelectedValue.Trim();
            if (re.register(tbp).Equals("1"))
            {
                this.Label1.Text = "<script>alert('注册成功，E-mail将作为你的登录用户名！')</script>";
            }
            else
            {
                this.Label1.Text = "<script>alert('注册失败！')</script>";

            }
        }
        else
        {
            this.Label1.Text = "<script>alert('您已登录！')</script>";

        }
    }
    protected void ddlp_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (Session["person"] == null)
        {
            this.Label1.Text = "<script>show();</script>";
        }
        else
        {
            this.Label1.Text = "<script>alert('您已登陆！')</script>";
        }
    }
}